package com.test.webflux.config;

import com.test.webflux.config.router.CommonRouter;
import com.test.webflux.config.router.ProductRouter;
import com.test.webflux.config.router.UserRouter;
import com.test.webflux.service.ProductService;
import com.test.webflux.service.UserService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 * 第三种路由类方式  组合路由
 *
 * @Description
 * @Author lingmin
 * @Date 2025/4/14 16:27
 **/
@Configuration
public class AppCombinedRouterConfig {


    @Bean
    public RouterFunction<ServerResponse> combinedRoutes(
            UserService userService , ProductService productService) {
        CommonRouter commonRouter = new CommonRouter();
        UserRouter userRouter = new UserRouter();
        ProductRouter productRouter = new ProductRouter();
        return  commonRouter.commonRoutes().and(userRouter.userRoutes(userService))
                .and(productRouter.productRoutes(productService));
    }
}
